class DirectMessage < ActiveRecord::Base
  
  def self.get_dm_by_id(id)
    dm = find_by_sql("SELECT * FROM direct_messages WHERE post_from='#{id}' OR post_to='#{id}' ORDER BY post_at DESC LIMIT 30")
  end
  
  def self.get_dm_count_by_id(id)
    find_by_sql("SELECT * FROM direct_messages WHERE post_to='#{id}' ORDER BY post_at DESC LIMIT 30").length
  end
  
end
